package com.teamc.team.service.impl;

import com.teamc.team.entity.Link;
import com.teamc.team.mapper.LinkMapper;
import com.teamc.team.service.ILinkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teamc.team.vo.AdminOrderVO;
import com.teamc.team.vo.UserOrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ding
 * @since 2021-06-10
 */
@Service
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements ILinkService {

    @Autowired
    private LinkMapper mapper;

    @Override
    public int deleteLinkByName(String name) {
        HashMap<String, Object> s = new HashMap<>();
        s.put("user_id",name);
        return mapper.deleteByMap(s);
    }

    @Override
    public int deleteLinkByLinkId(Integer id) {
        HashMap<String, Object> s = new HashMap<>();
        s.put("link_id",id);
        return mapper.deleteByMap(s);
    }

    @Override
    public List<AdminOrderVO> listAllLink() {
        return mapper.listAllVO();
    }

    @Override
    public List<AdminOrderVO> listAllUnReturned() {
        return mapper.listAllVOByNotReturned();
    }

    @Override
    public List<AdminOrderVO> listAllReturned() {
        return mapper.listAllVOByReturned();
    }

    @Override
    public List<AdminOrderVO> listAllByName(String name) {
        return mapper.listAllVOByName(name);
    }

    @Override
    public int returnObject(Integer x) {
            Link t = new Link();
            t.setLinkId(x);
            t.setInDate(LocalDate.now());
            return mapper.updateById(t);
    }

    @Override
    public List<UserOrderVO> listAllUserVO() {
        mapper.listAllUserVO();
        return null;
    }


    @Override
    public List<UserOrderVO> listAllVOForUser(String id) {
        return mapper.listAllVOForUser(id);
    }

    @Override
    public List<UserOrderVO> listAllVOByNotReturnedForUser(String id) {
        return mapper.listAllVOByNotReturnedForUser(id);
    }

    @Override
    public List<UserOrderVO> listAllVOByReturnedForUser(String id) {
        return mapper.listAllVOByReturnedForUser(id);
    }

    @Override
    public AdminOrderVO listAllVOByLinkId(Integer x) {
        return mapper.listAllVOByLinkId(x);
    }
}
